import { defineComponent, h } from "vue";
import { dayjs } from "element-plus";

type TMomentProps = {
  tag?: string;
  format?: string;
  placeholder?: string;
  value?: string | number | Date;

  isUnix?: boolean
};

export default defineComponent(
  ({ value, tag = "span", isUnix, placeholder, format = "YYYY/MM/DD HH:mm:ss" }: TMomentProps) => {
    return () => h(tag, value ? dayjs(isUnix ? `${value}000` : value).format(format) : placeholder);
  },
  {
    props: ["value", "tag", "format", "placeholder"],
  }
);
